package com.redhat.redwork.widget;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.components.Form;
import org.apache.struts2.views.annotations.StrutsTag;
import org.apache.struts2.views.annotations.StrutsTagAttribute;
import org.apache.struts2.views.annotations.StrutsTagSkipInheritance;

import com.opensymphony.xwork2.util.ValueStack;

/**
 * form for search grid
 * @author Justin
 *
 */
@StrutsTag(name = "gridForm", tldTagClass = "", description = "form for Grid")
public class GridForm extends Form{
	
	public static final String            TEMPLATE       = "gridform";
    public static final String            TEMPLATE_CLOSE = "gridform-close";
    
    protected String grid; 
    
	protected GridForm(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		super(stack, request, response);
	}
	
	@Override
	protected void evaluateExtraParams() {
		super.evaluateExtraParams();

		addParameter("grid", findString(grid));
	}
	
	@Override
	public String getDefaultOpenTemplate() {
		return TEMPLATE;
	}

	@Override
	protected String getDefaultTemplate() {
		return TEMPLATE_CLOSE;
	}
	
	@Override
	@StrutsTagSkipInheritance
	public void setTheme(String theme) {
		super.setTheme(theme);
	}
	
	@Override
	public String getTheme() {
		return "redwork";
	}

	@StrutsTagAttribute(description = "target grid")
	public void setGrid(String grid) {
		this.grid = grid;
	}
}
